package com.heima.order.service.impl;

import com.heima.order.entity.Order;
import com.heima.order.entity.User;
import com.heima.order.feign.UserClient;
import com.heima.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements IOrderService {

    @Autowired
    private UserClient userClient;

    @Override
    public Order getById(Long id) {
        Order order = new Order();
        order.setId(id);
        // 为方便测试,假设用户id和订单id一致
        order.setUserId(id);
        order.setName("iphone13 Pro Max");
        order.setPrice(9999L);
        order.setNum(2);
        // 查询订单中的用户
        User user = userClient.getById(id);
        order.setUser(user);
        return order;
    }
}
